"""
Test for the Sensor Type Classes
"""


#from datetime import datetime
import datetime

#Python Module Imports
import sqlalchemy.exc


import json
import cogentviewer.models as models
import cogentviewer.tests.base as base

class TestRoomType(base.ModelTestCase):

    def _serialobj(self):
        """Helper Method to provde an object to serialise"""
        theItem = models.RoomType(id=1,
                                  name="Test Room")
        return theItem

    def _dictobj(self):
        """Helper method to provide a dictionay representaiton of the object
        generated by _serialobj()"""

        theDict = {"__table__":"RoomType",
                   "id":1,
                   "name":"Test Room"}
        return theDict

    def testEq(self):
        """Test for Equality"""
        item1 = models.RoomType(id=1,
                                name="Test Room")
        item2 = models.RoomType(id=1,
                                name="Test Room")

        self.assertEqual(item1,item2)
        self.assertReallyEqual(item1,item2)

        #Not massivly botherered about Id at the moment
        item2.id = 5
        self.assertEqual(item1,item2)
        self.assertReallyEqual(item1,item2)

    def testNEQ(self):
        item1 = models.RoomType(id=1,
                                name="Test Room")
        item2 = models.RoomType(id=1,
                                name="Test Room")

        self.assertEqual(item1,item2)

        item2.name = "FOO"
        self.assertNotEqual(item1,item2)
        self.assertReallyNotEqual(item1,item2)

    def testCmp(self):
        """Test Compaison function

        (actually __lt__ for Py3K Comat)"""

        item1 = models.RoomType(id=1,
                                name="Test Room")
        item2 = models.RoomType(id=1,
                                name="Test Room")

        
        self.assertEqual(item1,item2)
        
        #Order On Name
        item2.name = "A_Test"
        self.assertGreater(item1,item2)

        item2.name = "Z_Test"
        self.assertLess(item1,item2)
